home *** CD-ROM | disk | FTP | other *** search
- /*
- dshell v3
-
- 本文表示関係
- */
-
- #include "dsh.h"
-
-
- static uchar *print_job24(uchar *, int);
- static uchar *print_job12(uchar *);
-
-
- /*
- 一行表示ルーチン
- */
- void
- p_lin(int lin, int pl)
- {
- uchar *ptr;
- int in;
-
- /* cut ↓ */
- int cut_no, cut_line;
- /* cut ↑ */
-
- FNTADR_TABLE *font16P;
-
- #ifdef DEBUG
- {
- char *tbf[40];
- sprintf(tbf,"lhp=%x:lin=%d,pl=%d:lhp[lin]=%x",lhp,lin,pl,(lhp+lin));
- w_open();
- w_mes(0,tbf);
- w_mes(1,"hit any key");
- w_wait(0);
- }
- #endif
-
-
- B_LOCATE(0, pl + 1);
- B_COLOR(3);
- B_ERA_AL();
-
- if (lin < 0 || lin >= lpmx) {
- return;
- }
-
- /*
- ! 一つ上の行に24dot表示指示があった時の、24dot下半分表示の処理
- */
- if (lin > 0) {
- ptr = lhp[lin - 1];
- while (in = dinstr(ptr, LARGE_IDSTR)) {
- int px, py;
- uchar c;
-
- ptr += in - 1 + 2; // ptr:'<DEL>W' の直後
- px = (*ptr++ - NUM_BIAS) << 3;
- py = (pl + 1) << 4;
-
- curColor = *ptr++ - NUM_BIAS;
- tcolor(curColor);
- while ((c = *ptr++) != NORM_CHAR) { /* 24dot下半分の表示 */
- int cc;
- int copl;
- struct FNTBUF buf, *bufp;
-
- if (c == '\x1b' && (cc = isEscSeq(ptr))) {
- ptr += cc;
- tcolor(curColor);
- continue;
- }
- cc = c;
- if (iskanji1(c))
- cc = (cc << 8) + *ptr++;
- FNTGET(12, cc, &buf);
- buf.yl = 12;
- copl = (buf.xl == 12) ? 24 : 36; /* 横12dot/24dotの場合 */
- bufp = (struct FNTBUF *)((char *)&buf + copl);
- bufp->yl = buf.yl;
- bufp->xl = buf.xl;
- TEXTPUT(px, py, bufp);
- px += bufp->xl;
- }
- tcolor(0);
- }
- }
-
-
- /*
- ! 現在行の処理
- */
- B_LOCATE(0, pl + 1);
-
- ptr = lhp[lin];
- if (*ptr == CTRL_CHAR) {
- if (debugMode && *(ptr + 1) == VEXEC_CHAR) {
- int colorBak = B_COLOR(2);
- B_PUTC(L'◎');
- ptr += 2;
- B_COLOR(colorBak);
- } else if ((*(ptr + 1) | 0x20) == VEXEC_CHAR) {
- B_PUTC(L'◎');
- ptr += 2;
- } else if (*(ptr + 1) == HR_CHAR) {
- ptr += 2;
- }
- }
- font16P = &defFont16;
- while (*ptr && (in = dinstrchr(ptr, CTRL_CHAR))) {
- int px;
- uchar *p;
-
- p = ptr;
- ptr += in;
- *--ptr = '\0';
- B_PRINT(p);
- *ptr++ = CTRL_CHAR;
-
- switch (*ptr++) {
- case LARGE_CHAR:
- ptr = print_job24(ptr, pl);
- break;
- case SMALL_CHAR:
- ptr = print_job12(ptr);
- break;
- case CUT_CHAR:
- cut_no = (*ptr++ - NUM_BIAS) << 6;
- cut_no += *ptr++ - NUM_BIAS;
- cut_line = *ptr++ - NUM_BIAS;
- px = *ptr++ - NUM_BIAS;
- tcolor(-1);
- px += cut_print(px * 8, pl * 16 + 16, &(cut[cut_no]), cut_line);
- tcolor(0);
- B_LOCATE(px, pl + 1);
- break;
- case BOX_CHAR:
- {
- int x, y, xy = B_LOCATE(-1, -1), colorBak;
- ushort cc;
-
- y = lowWord(xy);
- x = *ptr++ - NUM_BIAS;
- B_LOCATE(x, y);
- colorBak = B_COLOR(*ptr++ - NUM_BIAS);
- cc = *ptr++;
- cc = (cc << 8) | *ptr++;
- B_PUTC(cc);
- B_RIGHT(*ptr++ - NUM_BIAS);
- cc = *ptr++;
- cc = (cc << 8) | *ptr++;
- B_PUTC(cc);
- B_LOCATE(highWord(xy), y);
- B_COLOR(colorBak);
- }
- break;
- case FONT_CHAR:
- {
- FNTADR_TABLE *fp;
- int fontNo;
-
- if ((fp = malloc(sizeof(FNTADR_TABLE))) != NULL) {
- *fp = *font16P;
- fp->prev = font16P;
- font16P = fp;
- while ((fontNo = *ptr++) != NORM_CHAR) {
- fontNo -= NUM_BIAS;
- if (font16[fontNo].size > 0) {
- uchar *pat = font16[fontNo].pat;
- if (font16[fontNo].sect == 0) {
- fp->table[0] = pat;
- } else {
- int n;
- uchar **p = &fp->table[font16[fontNo].sect];
- for (n = font16[fontNo].size; --n >= 0;) {
- *p++ = pat;
- pat += 32*94;
- }
- }
- }
- }
- setFont16(font16P);
- } else {
- while ((fontNo = *ptr++) != NORM_CHAR)
- ;
- }
- }
- break;
- case EFONT_CHAR:
- if (font16P->prev != NULL) {
- FNTADR_TABLE *fp = font16P;
- font16P = font16P->prev;
- free(fp);
- if (font16P->prev == NULL) {
- setFont16(NULL);
- setHanFont16(defFont16.table[0]);
- } else {
- setFont16(font16P);
- }
- }
- break;
- case TYPE_CHAR:
- B_PRINT(--ptr);
- px = B_PUTC('>');
- if (highWord(px) > CWIDTH) {
- B_LOCATE(CWIDTH - 2, lowWord(px));
- B_PUTC(L'…');
- }
- goto RETURN;
- case NULTYPE_CHAR:
- goto RETURN;
- default:
- B_PRINT(--ptr);
- goto RETURN;
- }
- }
- if (*ptr)
- B_PRINT(ptr);
- RETURN:
- if (font16P->prev != NULL) {
- while (font16P->prev != NULL) {
- FNTADR_TABLE *fp = font16P;
- font16P = font16P->prev;
- free(fp);
- }
- setFont16(NULL);
- setHanFont16(defFont16.table[0]);
- }
- }
-
- /*
- 24ドット表示
- */
- static uchar *
- print_job24(uchar *ptr, int pl)
- {
- int px, py;
- int cnt, cnt2;
- int i;
-
- struct FNTBUF buf;
- uchar c;
-
- px = (*ptr++ - NUM_BIAS) * 8; /* ビットマップ座標を得る→X */
- py = (pl + 1) * 16 + 4; /* →Y */
- tcolor(*ptr++ - NUM_BIAS);
- cnt2 = 0;
- while ((c = *ptr++) != NORM_CHAR) { /* 24dot上半分の表示 */
- int cc;
-
- if (c == '\x1b' && (cc = isEscSeq(ptr))) {
- c = *(ptr + cc);
- *(ptr + cc) = '\0';
- B_PRINT(ptr - 1);
- ptr += cc;
- *ptr = c;
- tcolor(curColor);
- continue;
- }
- cc = c;
- if (iskanji1(c))
- cc = (cc << 8) + *ptr++;
- FNTGET(12, cc, &buf);
- buf.yl = 12;
- TEXTPUT(px, py, &buf);
- px += buf.xl;
- cnt2 += buf.xl; /* buf.xl= 12 or 24 */
- }
- tcolor(0);
- cnt += (cnt2 + 12) / 24;
- if (i = (cnt2 + 7) / 8)
- B_RIGHT(i);
-
- return ptr;
- }
-
- /*
- 12ドット表示
- */
- static uchar *
- print_job12(uchar *ptr)
- {
- int n;
-
- n = dinstrchr(ptr, NORM_CHAR);
- if (n > 0) {
- ptr[--n] = '\0';
- B_PRINT12(ptr);
- ptr += n;
- *ptr++ = NORM_CHAR;
- }
- return ptr;
- }
-
- /*
- 画面全体を表示
- */
- void
- p_scr()
- {
- int i, n = lp;
-
- for (i = 32; i < 32 + 30; i++)
- p_lin(n++, i);
- vsync();
- if (GMODE == 0)
- dpalet(0, gr_col[0]);
- dpalet(-3, tx_col[3]);
- TXRASCPY(0x8404, 16/4*30, 0x0003);
- }
-